package com.hdu.hdu.interceptorFIlter;


import com.hdu.hdu.interceptor.Interceptor;

import java.util.List;


/**
 * 用来结合配置中心控制拦截器是否需要跳过
 */
public class ConfigInterceptorFilter implements InterceptorFilter {

    // supportInterceptorNames 可以动态刷新
    private List<String> supportInterceptorNames;

    public ConfigInterceptorFilter(List<String> supportInterceptorNames) {
        this.supportInterceptorNames = supportInterceptorNames;
    }

    public void refresh(List<String> supportInterceptorNames) {
        this.supportInterceptorNames = supportInterceptorNames;
    }

    @Override
    public boolean needProcess(Interceptor<?> interceptor) {
        return supportInterceptorNames.contains(interceptor.getClass().getName());
    }
}
